<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <!-- 
        匿名函数没有进行回调的时候this指向的是window
        return 
     -->

    <script>
        function txt(n)
        {
            var total=0;
            var n=n;
            function counter()  //变量延时了 并进行了传递
            {
                total=total+13;
                if(n>3)
                {
                    total+=(n-3)*5
                }
                return total
            }
            function raise()
            {
                total+=10
                return total
            }
            return{
                counter:counter,
                raise:raise
            }
        }
        var t=txt(5)
        console.log('计算有拥堵的价格',t.raise());//这里改变了运行顺序就改变了值
        console.log('计算没有拥堵的价格',t.counter());
        
    </script>
    
</body>
</html>